<template>
  <div class="teacher-comment">
    <div class="item" @click="router({path: './editTeacher',query:{id:info.id}})">
      <img :src="info.img" class="head-img" alt="">
      <div class="name-con">
        <p class="name">{{info.truename}}</p>
        <p class="phone">{{info.mobile}}</p>
      </div>
      <span class="gl">管理</span><img src="@/assets/mddk04.png" class="arrow" alt="">
    </div>
    <div v-wechat-title="$route.meta.title"></div>
    <span class="comment-num">ta的点评 {{info.count}}次</span>
    <div class="mescroll"  ref="mescroll">  
      <div class="list">
        <div v-for="(item,index) in lists" class="list-item" @click="router({path: './storeComment',query:{id:item.id}})">
          <div class="type">
            <p class="title">{{item.txt}}</p>
            <p class="time">{{item.create_time}}</p>
          </div>
          <div class="is-comment">
            <p>{{item.review_txt}}</p>   
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import {teacherdetail,teacherreview} from '@/api/api'
  import MeScroll from 'mescroll.js'
  import 'mescroll.js/mescroll.min.css'

  export default {
    components: {
    },
    data () {
      return {
        info:[],
        lists:[],
      }
    },
    created () {
      this.id = this.$route.query.id
      this.detail()
      
    },
    mounted () {
      this.mescroll = new MeScroll(this.$refs.mescroll, { 
        up: {
          callback: this.upCallback
        }
      })
    },
    methods: {
      router (path) {
        this.$router.push(path)
      },
      detail(){
        teacherdetail(this.id).then((res) =>{
          console.log(res)
          this.info=res.data.info
          this.$route.meta.title = this.info.truename+'讲师'
          console.log(this.info)
        }).catch((err) => {
          console.dir(err)
        })
      },
      upCallback (page) {
        teacherreview(this.id,page.num, page.size).then((res) => {
          console.log(res)
          if (page.num == 1){
            this.lists = []
          }
          if(res.data.info == null){
            this.mescroll.endErr()
            return
          }
          this.$nextTick(() => {
            this.mescroll.endSuccess(res.data.info.length);
          })
            this.lists = this.lists.concat(res.data.info)
        }).catch((err) => {
          console.dir(err)
          this.mescroll.endErr()
        })
      },
    }
  }
</script>

<style lang="stylus" scoped>
.teacher-comment
  width 100%
  height 100vh
  overflow hidden
  background-color #fff  
  .mescroll
    position fixed
    top 12.3rem
    bottom 0
    height auto
    width 100vw
    overflow-x hidden
    .top-img
      float left
    .search
      float left
      width 92%
      margin-left 4%
      text-align center
      background-color #fff
      height 4.5rem
      line-height 4.5rem
      margin-top -2.25rem
      margin-bottom 1rem
      img
        display inline-block
        vertical-align middle
        width 1.6rem
      span
        display inline-block
        vertical-align middle
        font-size 1.3rem
        color #172F6D
        margin-left .5rem
  .item
    padding 1rem 1.5rem
    position relative
    height 7.8rem
    box-sizing border-box
    .gl
      width 5rem
      right 3.2rem
      font-size 1.3rem
      color #19316B
      text-align right
      height 7.8rem
      line-height 7.8rem
      position absolute
      top 0
    .arrow
      position absolute
      width .6rem
      right 1.5rem
      top 3.4rem
    .head-img
      float left
      width 6rem
      margin-right 1.2rem
    .name-con
      .name
        color #333333
        font-size 1.7rem
        font-weight bold
        line-height 1.8rem
        margin-bottom .6rem
        text-overflow ellipsis
        overflow hidden
        white-space nowrap
        margin-top: .9rem;
      .phone
        font-size 1.2rem
        line-height 1.8rem
        color #999
  .comment-num
    line-height 4.5rem
    height 4.5rem
    font-size 1.3rem
    color #333
    padding-left 1.5rem
    background-color #f5f5f5
    display block
  .list
    .list-item
      padding 1.5rem
      display flex
      border-bottom 1px solid #e6e6e6
      &:last-child
        border none
      .title
        color #333
        font-size 1.5rem
        font-weight 500
      .time
        color #999
        font-size 1.2rem
      .type
        flex 2
      .is-comment
        flex 1
        color #172F6D
        font-size 1.3rem
        line-height 4rem
        height 4rem
        text-align right
</style>
